package com.hq.ims.data.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.hq.ims.data.entityenum.EnumAccountStatus;
import com.hq.mybatis.base.BaseModel;
import com.hq.mybatis.base.annotation.EntityEnDe;
import com.hq.utils.util.StringUtils;
import com.hq.web.inf.user.ITokenUserInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.ibatis.type.Alias;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@Alias("User")
@TableName(value = "user")
@ApiModel(value = "用户表")
public class User extends BaseModel<User> implements Serializable, ITokenUserInfo {

    @ApiModelProperty(value = "创建数据用户ID")
    @TableId(value = "`user_id`", type = IdType.ASSIGN_UUID)
    private String userId;

    @ApiModelProperty(value = "创建时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "`create_date_time`", fill = FieldFill.INSERT)
    private LocalDateTime createDateTime;

    @ApiModelProperty(value = "更新时间")
    @JSONField(ordinal = 0, format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "`update_date_time`", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateDateTime;

    @ApiModelProperty(value = "数据版本号")
    @Version
    @TableField(value = "`version`")
    private Integer version;

    @ApiModelProperty(value = "登录账号")
    @TableField(value = "`account`")
    private String account;

    @ApiModelProperty(value = "密码")
    @TableField(value = "`pwd`")
    private String pwd;

    @EntityEnDe
    @ApiModelProperty(value = "用户手机号")
    @TableField(value = "`mobile`")
    private String mobile;

    @ApiModelProperty(value = "头像地址url")
    @TableField(value = "`avatar_url`")
    private String avatarUrl;

    @ApiModelProperty(value = "账号状态")
    @TableField(value = "`account_status`")
    private EnumAccountStatus accountStatus;

    @ApiModelProperty(value = "最后登录记录id")
    @TableField(value = "last_login_id")
    private String lastLoginId;

    @ApiModelProperty(value = "最后登陆时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "`last_login_date_time`")
    private LocalDateTime lastLoginDateTime;

    @ApiModelProperty(value = "性别")
    @TableField(value = "sex")
    private Boolean sex;

    @ApiModelProperty(value = "身份证号")
    @TableField(value = "id_card")
    private String idCard;

    @ApiModelProperty(value = "生日")
    @TableField(value = "birthday")
    private LocalDate birthday;

    @ApiModelProperty(value = "微信用户openid")
    @TableField(value = "wx_openid")
    private String wxOpenid;

    @ApiModelProperty(value = "微信用户名称")
    @TableField(value = "wx_nick_name")
    private String wxNickName;

    @EntityEnDe
    @ApiModelProperty(value = "真实名称")
    @TableField(value = "real_name")
    private String realName;

    @ApiModelProperty(value = "邮箱")
    @TableField(value = "e_mail")
    private String eMail;

    @ApiModelProperty(value = "是否删除")
    @TableField(value = "is_del")
    private Boolean isDel;

    @ApiModelProperty(value = "推送id")
    @TableField(value = "push_id")
    private String pushId;

    @ApiModelProperty(value = "是否系统管理员")
    @TableField(value = "is_admin")
    private Boolean isAdmin;

    @ApiModelProperty(value = "是否需要强制列新密码")
    @TableField(value = "is_need_force_up_pwd")
    private Boolean isNeedForceUpPwd;


    @Override
    public String getId() {
        return this.userId;
    }

    @Override
    public String getCompanyId() {
        return StringUtils.EMPTY;
    }

    @Override
    public String getDepartmentId() {
        return StringUtils.EMPTY;
    }

    @Override
    public Object getCustomData() {
        return StringUtils.EMPTY;
    }

    @Override
    public String secret() {
        return StringUtils.EMPTY;
    }

}
